#include <cstdio>
#include <cstring>

long long fac[ 2 ][ 3761600 ], pr[ 2 ];
int cnt;

void initprime( )
{
    int i, j;
    pr[ cnt++ ] = 97;
    pr[ cnt++ ] = 3761599;
    for ( i = 0; i < cnt; i++ )
    {
        fac[ i ][ 0 ] = 1;
        for ( j = 1; j < pr[ i ]; j++ )
            fac[ i ][ j ] = fac[ i ][ j - 1 ] * j % pr[ i ];
    }
}

long long mypow( long long x, long long n, long long p )
{
    long long ret = 1, pos = 1;
    while ( pos <= n ) pos <<= 1;
    pos >>= 1;
    while ( pos )
    {
        ret = ret * ret % p;
        if ( pos & n ) ret = ret * x % p;
        pos >>= 1;
    }
    return ret;
}

long long C( long long n, long long m, long long p, long long *fac )
{
    if ( m > n ) return 0;
    return fac[ n ] * mypow( fac[ n - m ] * fac[ m ] % p, p - 2, p ) % p;
}

long long lucas( long long n, long long m, long long p, long long *fac )
{
    if ( m == 0 ) return 1;
    return lucas( n / p, m / p, p, fac ) * C( n % p, m % p, p, fac ) % p;
}

long long solve( int n, int m, int p )
{
        if ( m > n - m ) m = n - m;
        if ( m == 0 )
        return n % pr[ p ];
    return lucas( n, m, pr[ p ], fac[ p ] );
}

long long extgcd( long long a, long long b, long long &x, long long &y )
{
    if ( b == 0 ) { x = 1; y = 0; return a; }
    long long d = extgcd( b, a % b, x, y );
    long long t = x; x = y; y = t - a / b * y;
    return d;
}

long long china( long long b1, long long b2 )
{
    long long n = pr[ 0 ] * pr[ 1 ], x, y;
    extgcd( pr[ 0 ], pr[ 1 ], x, y );
    return ( x * pr[ 0 ] * b2 + y * pr[ 1 ] * b1 + n ) % n;
}

int main( )
{
    int n, m, k, t, cas = 1, a[ 16 ], i;
    long long ans1, ans2;
    initprime( );
    scanf("%d", &t);
    while ( t-- )
    {
        scanf("%d%d%d", &n, &m, &k);
        for ( i = 0; i < k; i++ )
            scanf("%d", &a[ i ]);
        a[ k ] = m;
        ans1 = ans2 = 1;
        for ( i = 0; i < k; i++ )
        {
            ans1 = ans1 * solve( n + a[ i + 1 ] - a[ i ] - 1, a[ i + 1 ] - a[ i ], 0 ) % pr[ 0 ];
            ans2 = ans2 * solve( n + a[ i + 1 ] - a[ i ] - 1, a[ i + 1 ] - a[ i ], 1 ) % pr[ 1 ];
    }
    printf("Case #%d: %lld\n", cas++, china( ans1, ans2 ));
    }
    return 0;
}
